import java.util.Scanner;

/**
 * 4. 特殊年份
 * https://www.lanqiao.cn/problems/2377/learning/?page=1&first_category_id=1&second_category_id=3&tag_relation=intersection&tags=%E7%9C%81%E8%B5%9B,2021&sort=pass_rate&asc=0
 */
public class Main10 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int count = 0;
        for(int i = 0;i < 5;i++) {
            int year = scan.nextInt();
            int a = year / 1000;
            int b = year / 100 % 10;
            int c = year /10 % 10;
            int d = year % 10;
            if(a == c && d - b == 1) {
                count++;
            }
        }
        System.out.println(count);
        scan.close();
    }
}
